Field
The present disclosure relates to mobile terminal field, and more particularly to a data transmission method and a mobile terminal.
Background
In some situations, processors of mobile terminals (such as mobile phones) need to output interface data in multiple types of formats, for example, Inter-Integrated Circuit (I2C), universal asynchronous receiver/transmitter (UART), serial peripheral interface (SPI), and so on. However, in a situation that number of dedicated interfaces of a processor is not sufficient, it is required to utilize general purpose input/output (GPIO) ports to simulate other types of interfaces. Meanwhile, the processor is necessary to control when data and clocks are transmitted or received by time delays. For I2Cs and SPIs which are synchronous data, accuracy of the time delays is not required. Data transmission and reception can be accurately completed via clock triggers as long as the clocks can keep up with the data. However, for UARTs which is an asynchronous communication, the data is collected via the time delays after a receiving terminal detects a starting bit. When the time delays are not accurate, the data is easily wrongly received. Accordingly, the accuracy of the time delays is quite important for the GPIO ports which simulate UART serial ports.
A processor of the mobile terminal can process multiple types of tasks. However, in order to ensure the accuracy of the time delays, it is required to lock the processor to be protected from all interrupting responses. This ensures that the processor does not process other tasks due to other interrupts when a time delay function is operated. As such, another problem is caused. If data, which is transmitted by the simulated UART serial ports takes too long, it is necessary to lock the processor for a long time. Finally, the processor crashes because it is too late to process various interrupts.